<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap/dist/css/bootstrap.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/animate.css/animate.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/font-awesome/css/font-awesome.min.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/simple-line-icons/css/simple-line-icons.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-editable/css/bootstrap-editable.min.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/app/css/font.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/app/css/app.css" type="text/css" />
</head>
<body>
<div class="wrapper-md">
   <div class="panel panel-default">
    <div class="panel-heading">
    	<i class="fa fa-home"></i>&nbsp;首页&nbsp;&gt;&nbsp;&nbsp;用户组列表
    	<button class="btn btn-primary btn-xs menu-add pull-right" onclick="add()">添加用户组</button>
    </div>
    <div class="table-responsive">
		<table class="table table-bordered table-striped table-hover table-condensed b-t b-light">
			<thead>
				<tr>
				<th>用户组名</th>
				<th width="300">操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="data" item="v">
				<tr menuId="${menu.id}" pid="${menu.parentId}">
					<td><span class="menu-name">{$v['title']}</span></td>
					<td>
						<button class="btn btn-info btn-xs menu-edit" ruleId="{$v['id']}" ruleTitle="{$v['title']}" onclick="edit(this)">修改</button>
						<a class="btn btn-danger btn-xs menu-delete" href="javascript:if(confirm('确定删除？'))location='{:U('Admin/Rule/delete_group',array('id'=>$v['id']))}'">删除</a>
						<a href="{:U('Admin/Rule/rule_group',array('id'=>$v['id']))}" class="btn btn-default btn-xs menu-edit">分配权限</a>
						<a href="{:U('Admin/Rule/check_user',array('group_id'=>$v['id']))}" class="btn btn-default btn-xs menu-edit">添加成员</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
    </div>
  </div>
</div>

<!-- 添加用户组模态框开始 -->
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					添加用户组
				</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" action="{:U('Admin/Rule/add_group')}" method="post">
					<input type="hidden" name="pid" value="0">
					<div class="line line-dashed b-b line-lg pull-in"></div>
					<div class="form-group m-b-none">
                        <label class="col-sm-3 control-label" for="input-id-1">用户组名：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" data-form-un="1470118834084.755">
                        </div>
                    </div>
                    <div class="form-group m-b-none m-t-none m-l-none m-r-none">
	                    <div class="line line-dashed b-b line-lg pull-in"></div>
			            <div class="col-sm-4 col-sm-offset-2">
			                <button type="submit" class="btn btn-primary">提交</button>
			            </div>
			        </div>
				</form>
			</div>
		</div>
	</div>
</div>
<!-- 添加用户组模态框结束 -->

<!-- 修改用户组模态框开始 -->
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					修改用户组
				</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" action="{:U('Admin/Rule/edit_group')}" method="post">
					<input type="hidden" name="id">
					<div class="line line-dashed b-b line-lg pull-in"></div>
					<div class="form-group m-b-none">
                        <label class="col-sm-3 control-label" for="input-id-1">用户组名：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" data-form-un="1470118834084.755">
                        </div>
                    </div>
                    <div class="form-group m-b-none m-t-none m-l-none m-r-none">
	                    <div class="line line-dashed b-b line-lg pull-in"></div>
			            <div class="col-sm-4 col-sm-offset-2">
			                <button type="submit" class="btn btn-primary">提交</button>
			            </div>
			        </div>
				</form>
			</div>
		</div>
	</div>
</div>
<script src="__ADMIN_STATICS__/jquery/jquery.min.js"></script>
<script src="__ADMIN_STATICS__/bootstrap/dist/js/bootstrap.js"></script>
<script src="__ADMIN_STATICS__/bootstrap-editable/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function(){
	$.fn.editable.defaults.emptytext = '----';
	$('.menu-name').editable({

	});
	$('.menu-url').editable({
		
	});
	$('.menu-sort').editable({
		
	});
	$('.menu-show').editable({
		
	});
	$('.sort').click(function(){
		var id = $(this).parents('tr').attr('menuId');
		var a = $(this).find('a');
		var isShow = 0;
		if(a.hasClass('active')){
			isShow = 0;
			a.removeClass('active')
		}else{
			isShow = 1;
			a.addClass('active')
		}
		var para = {
				'menu.id':id,
				'menu.isShow':isShow
		}
		$ajax(para);
	});
	
	$ajax = function(para){
		$.post(updateUrl, para, function (data) {
			console.log(data);			
		});
	}
	
});
// 添加菜单
function add(){
	$("input[name='title']").val('');
	$('#bjy-add').modal('show');
}

// 修改菜单
function edit(obj){
	var ruleId=$(obj).attr('ruleId');
	var ruletitle=$(obj).attr('ruletitle');
	$("input[name='id']").val(ruleId);
	$("input[name='title']").val(ruletitle);
	$('#bjy-edit').modal('show');
}
</script>
</body>
</html>
